const EventEmitter = require('events');

const emitter = new EventEmitter();

emitter.on('foo', function (msg) {
    console.log('foo message:', msg);
});

emitter.emit('foo', 'The answer is 42');
// => foo message: The answer is 42
